package com.kitbox.hl.meshow.common.node;

import java.util.List;

/**
 * @Auther: honglei
 * @Date: 2019/8/22 11:32
 * @Description:
 */
public class TreeNode implements Tree {
    public static final String ROOT_NODE_ID = "-1";
    public static final String ROOT_NODE_NAME = "根结点";
    private String id;
    private String pId;
    private String name;
    private Boolean open;
    private Boolean checked = false;
    private String isMenu;
    private List<TreeNode> children;

    public String getNodeId() {
        return this.id.toString();
    }

    public String getNodeParentId() {
        return this.pId.toString();
    }

    public void setChildrenNodes(List childrenNodes) {
        this.children = childrenNodes;
    }

    public static TreeNode createRoot() {
        TreeNode root = new TreeNode();
        root.setChecked(false);
        root.setId("-1");
        root.setName("根结点");
        root.setOpen(true);
        root.setPId((String)null);
        return root;
    }

    public TreeNode() {
    }

    public String getId() {
        return this.id;
    }

    public String getPId() {
        return this.pId;
    }

    public String getName() {
        return this.name;
    }

    public Boolean getOpen() {
        return this.open;
    }

    public Boolean getChecked() {
        return this.checked;
    }

    public String getIsMenu() {
        return this.isMenu;
    }

    public List<TreeNode> getChildren() {
        return this.children;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setPId(String pId) {
        this.pId = pId;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setOpen(Boolean open) {
        this.open = open;
    }

    public void setChecked(Boolean checked) {
        this.checked = checked;
    }

    public void setIsMenu(String isMenu) {
        this.isMenu = isMenu;
    }

    public void setChildren(List<TreeNode> children) {
        this.children = children;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof TreeNode)) {
            return false;
        } else {
            TreeNode other = (TreeNode)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label95: {
                    Object this$id = this.getId();
                    Object other$id = other.getId();
                    if (this$id == null) {
                        if (other$id == null) {
                            break label95;
                        }
                    } else if (this$id.equals(other$id)) {
                        break label95;
                    }

                    return false;
                }

                Object this$pId = this.getPId();
                Object other$pId = other.getPId();
                if (this$pId == null) {
                    if (other$pId != null) {
                        return false;
                    }
                } else if (!this$pId.equals(other$pId)) {
                    return false;
                }

                Object this$name = this.getName();
                Object other$name = other.getName();
                if (this$name == null) {
                    if (other$name != null) {
                        return false;
                    }
                } else if (!this$name.equals(other$name)) {
                    return false;
                }

                label74: {
                    Object this$open = this.getOpen();
                    Object other$open = other.getOpen();
                    if (this$open == null) {
                        if (other$open == null) {
                            break label74;
                        }
                    } else if (this$open.equals(other$open)) {
                        break label74;
                    }

                    return false;
                }

                label67: {
                    Object this$checked = this.getChecked();
                    Object other$checked = other.getChecked();
                    if (this$checked == null) {
                        if (other$checked == null) {
                            break label67;
                        }
                    } else if (this$checked.equals(other$checked)) {
                        break label67;
                    }

                    return false;
                }

                Object this$isMenu = this.getIsMenu();
                Object other$isMenu = other.getIsMenu();
                if (this$isMenu == null) {
                    if (other$isMenu != null) {
                        return false;
                    }
                } else if (!this$isMenu.equals(other$isMenu)) {
                    return false;
                }

                Object this$children = this.getChildren();
                Object other$children = other.getChildren();
                if (this$children == null) {
                    if (other$children != null) {
                        return false;
                    }
                } else if (!this$children.equals(other$children)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof TreeNode;
    }

    @Override
    public int hashCode() {
//        int PRIME = true;
        int result = 1;
        Object $id = this.getId();
        result = result * 59 + ($id == null ? 43 : $id.hashCode());
        Object $pId = this.getPId();
        result = result * 59 + ($pId == null ? 43 : $pId.hashCode());
        Object $name = this.getName();
        result = result * 59 + ($name == null ? 43 : $name.hashCode());
        Object $open = this.getOpen();
        result = result * 59 + ($open == null ? 43 : $open.hashCode());
        Object $checked = this.getChecked();
        result = result * 59 + ($checked == null ? 43 : $checked.hashCode());
        Object $isMenu = this.getIsMenu();
        result = result * 59 + ($isMenu == null ? 43 : $isMenu.hashCode());
        Object $children = this.getChildren();
        result = result * 59 + ($children == null ? 43 : $children.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "TreeNode(id=" + this.getId() + ", pId=" + this.getPId() + ", name=" + this.getName() + ", open=" + this.getOpen() + ", checked=" + this.getChecked() + ", isMenu=" + this.getIsMenu() + ", children=" + this.getChildren() + ")";
    }
}